home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 2 / AACD 2.iso / AACD / Programming / fpc / amigaunits / bullet.pas < prev    next >
Pascal/Delphi Source File  |  1998-09-22  |  17KB  |  427 lines

  1. {
  2.     This file is part of the Free Pascal run time library.
  3.  
  4.     A file in Amiga system run time library.
  5.     Copyright (c) 1998 by Nils Sjoholm
  6.     member of the Amiga RTL development team.
  7.  
  8.     See the file COPYING.FPC, included in this distribution,
  9.     for details about the copyright.
  10.  
  11.     This program is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14.  
  15.  **********************************************************************}
  16.  
  17. unit bullet;
  18.  
  19. INTERFACE
  20.  
  21. uses exec, utility;
  22.  
  23. type
  24.  
  25. { A GlyphEngine must be acquired via OpenEngine and is read-only }
  26.  
  27.  pGlyphEngine = ^tGlyphEngine;
  28.  tGlyphEngine = record
  29.     gle_Library  : pLibrary; { engine library }
  30.     gle_Name     : STRPTR;     { library basename: e.g. "bullet" }
  31.     { private library data follows... }
  32.  end;
  33.  
  34.  FIXED = Longint;             { 32 bit signed w/ 16 bits of fraction }
  35.  
  36.  pGlyphMap = ^tGlyphMap;
  37.  tGlyphMap = record
  38.     glm_BMModulo,               { # of bytes in row: always multiple of 4 }
  39.     glm_BMRows,                 { # of rows in bitmap }
  40.     glm_BlackLeft,              { # of blank pixel columns at left }
  41.     glm_BlackTop,               { # of blank rows at top }
  42.     glm_BlackWidth,             { span of contiguous non-blank columns }
  43.     glm_BlackHeight : WORD;     { span of contiguous non-blank rows }
  44.     glm_XOrigin,                { distance from upper left corner of bitmap }
  45.     glm_YOrigin     : FIXED;    {   to initial CP, in fractional pixels }
  46.     glm_X0,                     { approximation of XOrigin in whole pixels }
  47.     glm_Y0,                     { approximation of YOrigin in whole pixels }
  48.     glm_X1,                     { approximation of XOrigin + Width }
  49.     glm_Y1          : Integer;  { approximation of YOrigin + Width }
  50.     glm_Width       : FIXED;    { character advance, as fraction of em width }
  51.     glm_BitMap      : Pointer;  { actual glyph bitmap }
  52.  end;
  53.  
  54.  pGlyphWidthEntry = ^tGlyphWidthEntry;
  55.  tGlyphWidthEntry = record
  56.     gwe_Node  : tMinNode;        { on list returned by OT_WidthList inquiry }
  57.     gwe_Code  : WORD;           { entry's character code value }
  58.     gwe_Width : FIXED;          { character advance, as fraction of em width }
  59.  end;
  60.  
  61. const
  62. { Level 0 entries never appear in the .otag tag list, but appear in font
  63.  * specifications }
  64.      OT_Level0     = TAG_USER;
  65. { Level 1 entries are required to exist in the .otag tag list }
  66.      OT_Level1     = (TAG_USER OR $1000);
  67. { Level 2 entries are optional typeface metric tags }
  68.      OT_Level2     = (TAG_USER OR $2000);
  69. { Level 3 entries are required for some OT_Engines }
  70.      OT_Level3     = (TAG_USER OR $3000);
  71. { Indirect entries are at (tag address + data offset) }
  72.      OT_Indirect   = $8000;
  73.  
  74.  
  75. {******************************************************************}
  76. { font specification and inquiry tags }
  77.  
  78. { !  tags flagged with an exclaimation mark are valid for
  79.  *    specification.
  80.  *  ? tags flagged with a question mark are valid for inquiry
  81.  *
  82.  * fixed binary numbers are encoded as 16 bits of integer and
  83.  * 16 bits of fraction.  Negative values are indicated by twos
  84.  * complement of all 32 bits.
  85.  }
  86.  
  87. { !  OT_DeviceDPI specifies the target device dots per inch -- X DPI is
  88.  *    in the high word, Y DPI in the low word. }
  89.      OT_DeviceDPI  = (OT_Level0 OR $01);      { == TA_DeviceDPI }
  90.  
  91. { !  OT_DotSize specifies the target device dot size as a percent of
  92.  *    it's resolution-implied size -- X percent in high word, Y percent
  93.  *    in low word. }
  94.      OT_DotSize    = (OT_Level0 OR $02);
  95.  
  96. { !  OT_PointHeight specifies the requested point height of a typeface,
  97.  *    specifically, the height and nominal width of the em-square.
  98.  *    The point referred to here is 1/72".  It is encoded as a fixed
  99.  *    binary number. }
  100.      OT_PointHeight = (OT_Level0 OR $08);
  101.  
  102. { !  OT_SetFactor specifies the requested set width of a typeface.
  103.  *    It distorts the width of the em-square from that specified by
  104.  *    OT_PointHeight.  To compensate for a device with different
  105.  *    horizontal and vertical resolutions, OT_DeviceDPI should be used
  106.  *    instead.  For a normal aspect ratio, set to 1.0 (encoded as
  107.  *    $00010000).  This is the default value. }
  108.      OT_SetFactor   = (OT_Level0 OR $09);
  109.  
  110. { !  OT_Shear... specifies the Sine and Cosine of the vertical stroke
  111.  *    angle, as two fixed point binary fractions.  Both must be specified:
  112.  *    first the Sine and then the Cosine.  Setting the sine component
  113.  *    changes the Shear to an undefined value, setting the cosine
  114.  *    component completes the Shear change to the new composite value.
  115.  *    For no shear, set to 0.0, 1.0 (encoded as $00000000, $00010000).
  116.  *    This is the default value. }
  117.      OT_ShearSin   = (OT_Level0 OR $0a);
  118.      OT_ShearCos   = (OT_Level0 OR $0b);
  119.  
  120. { !  OT_Rotate... specifies the Sine and Cosine of the baselin rotation
  121.  *    angle, as two fixed point binary fractions.  Both must be specified:
  122.  *    first the Sine and then the Cosine.  Setting the sine component
  123.  *    changes the Shear to an undefined value, setting the cosine
  124.  *    component completes the Shear change to the new composite value.
  125.  *    For no shear, set to 0.0, 1.0 (encoded as $00000000, $00010000).
  126.  *    This is the default value. }
  127.      OT_RotateSin  = (OT_Level0 OR $0c);
  128.      OT_RotateCos  = (OT_Level0 OR $0d);
  129.  
  130. { !  OT_Embolden... specifies values to algorithimically embolden -- or,
  131.  *    when negative, lighten -- the glyph.  It is encoded as a fixed point
  132.  *    binary fraction of the em-square.  The X and Y components can be
  133.  *    changed indendently.  For normal characters, set to 0.0, 0.0
  134.  *    (encoded as $00000000, $00000000).  This is the default value. }
  135.      OT_EmboldenX  = (OT_Level0 OR $0e);
  136.      OT_EmboldenY  = (OT_Level0 OR $0f);
  137.  
  138. { !  OT_PointSize is an old method of specifying the point size,
  139.  *    encoded as (points * 16). }
  140.      OT_PointSize  = (OT_Level0 OR $10);
  141.  
  142. { !  OT_GlyphCode specifies the glyph (character) code to use with
  143.  *    subsequent operations.  For example, this is the code for an
  144.  *    OT_Glyph inquiry }
  145.      OT_GlyphCode  = (OT_Level0 OR $11);
  146.  
  147. { !  OT_GlyphCode2 specifies the second glyph code.  For example,
  148.  *    this is the right glyph of the two glyphs of an OT_KernPair
  149.  *    inquiry }
  150.      OT_GlyphCode2 = (OT_Level0 OR $12);
  151.  
  152. { !  OT_GlyphWidth specifies a specific width for a glyph.
  153.  *    It sets a specific escapement (advance) width for subsequent
  154.  *    glyphs.  It is encoded as a fixed binary fraction of the em-square.
  155.  *    To revert to using the font-defined escapement for each glyph, set
  156.  *    to 0.0 (encoded as $00000000).  This is the default value. }
  157.      OT_GlyphWidth = (OT_Level0 OR $13);
  158.  
  159. { !  OT_OTagPath and
  160.  * !  OT_OTagList specify the selected typeface.  Both must be specified:
  161.  *    first the Path and then the List.  Setting the path name changes
  162.  *    changes the typeface to an undefined value, providing the List
  163.  *    completes the typeface selection to the new typeface.  OTagPath
  164.  *    is the null terminated full file path of the .otag file associated
  165.  *    with the typeface.  OTagList is a memory copy of the processed
  166.  *    contents of that .otag file (i.e. with indirections resolved).
  167.  *    There are no default values for the typeface. }
  168.      OT_OTagPath   = (OT_Level0 OR OT_Indirect OR $14);
  169.      OT_OTagList   = (OT_Level0 OR OT_Indirect OR $15);
  170.  
  171. {  ? OT_GlyphMap supplies a read-only struct GlyphMap pointer that
  172.  *    describes a bitmap for a glyph with the current attributes. }
  173.      OT_GlyphMap   = (OT_Level0 OR OT_Indirect OR $20);
  174.  
  175. {  ? OT_WidthList supplies a read-only struct MinList of struct
  176.  *    GlyphWidthEntry nodes for glyphs that are defined from GlyphCode
  177.  *    to GlyphCode2, inclusive.  The widths are represented as fixed
  178.  *    binary fractions of the em-square, ignoring any effect of
  179.  *    SetFactor or GlyphWidth.  A width would need to be converted to
  180.  *    a distance along the baseline in device units by the
  181.  *    application. }
  182.      OT_WidthList  = (OT_Level0 OR OT_Indirect OR $21);
  183.  
  184. {  ? OT_...KernPair supplies the kern adjustment to be added to the
  185.  *    current position after placement of the GlyphCode glyph and
  186.  *    before placement of the GlyphCode2 glyph.  Text kern pairs are
  187.  *    for rendering body text.  Display kern pairs are generally
  188.  *    tighter values for display (e.g. headline) purposes.  The
  189.  *    adjustment is represented as a fixed binary fraction of the
  190.  *    em-square, ignoring any effect of SetFactor.  This number would
  191.  *    need to be converted to a distance along the baseline in device
  192.  *    units by the application. }
  193.      OT_TextKernPair = (OT_Level0 OR OT_Indirect OR $22);
  194.      OT_DesignKernPair = (OT_Level0 OR OT_Indirect OR $23);
  195.  
  196. {  ? OT_Underlined is an unsigned word which is used to request
  197.  *    algorithimic underlining for the engine when rendering the glyph.
  198.  *    Bullet.library currently does not support this tag, though it
  199.  *    may be used by other engines in the future.  The default for
  200.  *    any engine which supports this tag must be OTUL_None.  Engines which
  201.  *    do not support this tag should return an appropriate OTERR value.
  202.  *
  203.  *    As of V39, diskfont.library will request underlining if specified
  204.  *    in the TextAttr, or TTextAttr passed to OpenDiskFont().  Diskfont
  205.  *    will first request Broken underlining (like the Text() function
  206.  *    does when SetSoftStyle() is used), and then Solid underlining if
  207.  *    the engine returns an error.  If the engine returns an error for
  208.  *    both, then diskfont.library attempts to find, or create the best
  209.  *    non-underlined font that it can. }
  210.      OT_UnderLined        =  (OT_Level0 OR $24);
  211.  
  212.      OTUL_None            =  0;
  213.      OTUL_Solid           =  1;
  214.      OTUL_Broken          =  2;
  215.      OTUL_DoubleSolid     =  3;
  216.      OUTL_DoubleBroken    =  4;
  217.  
  218. {  ? OT_StrikeThrough is a boolean which is used to request
  219.  *    algorithimic strike through when rendering the glyph.
  220.  *    Bullet.library currently does not support this tag, though it
  221.  *    may be used by other engines in the future.  The default for
  222.  *    any engined which supports this tag must be FALSE.  Engines which
  223.  *    do not support this tag should return an appropriate OTERR value. }
  224.      OT_StrikeThrough     =  (OT_Level0 OR $25);
  225.  
  226.  
  227. {******************************************************************}
  228. { .otag tags }
  229.  
  230. { suffix for files in FONTS: that contain these tags }
  231.      OTSUFFIX     : PChar =  '.otag';
  232.  
  233. { OT_FileIdent both identifies this file and verifies its size.
  234.  * It is required to be the first tag in the file. }
  235.      OT_FileIdent =  (OT_Level1 OR $01);
  236.  
  237. { OT_Engine specifies the font engine this file is designed to use }
  238.      OT_Engine    =  (OT_Level1 OR OT_Indirect OR $02);
  239.      OTE_Bullet   =  'bullet';
  240.  
  241. { OT_Family is the family name of this typeface }
  242.      OT_Family    =  (OT_Level1 OR OT_Indirect OR $03);
  243.  
  244. { The name of this typeface is implicit in the name of the .otag file }
  245. { OT_BName is used to find the bold variant of this typeface }
  246.      OT_BName     =  (OT_Level2 OR OT_Indirect OR $05);
  247. { OT_IName is used to find the italic variant of this typeface }
  248.      OT_IName     =  (OT_Level2 OR OT_Indirect OR $06);
  249. { OT_BIName is used to find the bold italic variant of this typeface }
  250.      OT_BIName    =  (OT_Level2 OR OT_Indirect OR $07);
  251.  
  252. { OT_SymSet is used to select the symbol set that has the OT_YSizeFactor
  253.  * described here.  Other symbol sets might have different extremes }
  254.      OT_SymbolSet =  (OT_Level1 OR $10);
  255.  
  256. { OT_YSizeFactor is a ratio to assist in calculating the Point height
  257.  * to BlackHeight relationship -- high word: Point height term, low
  258.  * word: Black height term -- pointSize = ysize*<high>/<low> }
  259.      OT_YSizeFactor = (OT_Level1 OR $11);
  260.  
  261. { OT_SpaceWidth specifies the width of the space character relative
  262.  * to the character height }
  263.      OT_SpaceWidth = (OT_Level2 OR $12);
  264.  
  265. { OT_IsFixed is a boolean indicating that all the characters in the
  266.  * typeface are intended to have the same character advance }
  267.      OT_IsFixed    = (OT_Level2 OR $13);
  268.  
  269. { OT_SerifFlag is a boolean indicating if the character has serifs }
  270.      OT_SerifFlag  = (OT_Level1 OR $14);
  271.  
  272. { OT_StemWeight is an unsigned byte indicating the weight of the character }
  273.      OT_StemWeight = (OT_Level1 OR $15);
  274.  
  275.      OTS_UltraThin  =   8;     {   0- 15 }
  276.      OTS_ExtraThin  =  24;     {  16- 31 }
  277.      OTS_Thin       =  40;     {  32- 47 }
  278.      OTS_ExtraLight =  56;     {  48- 63 }
  279.      OTS_Light      =  72;     {  64- 79 }
  280.      OTS_DemiLight  =  88;     {  80- 95 }
  281.      OTS_SemiLight  = 104;     {  96-111 }
  282.      OTS_Book       = 120;     { 112-127 }
  283.      OTS_Medium     = 136;     { 128-143 }
  284.      OTS_SemiBold   = 152;     { 144-159 }
  285.      OTS_DemiBold   = 168;     { 160-175 }
  286.      OTS_Bold       = 184;     { 176-191 }
  287.      OTS_ExtraBold  = 200;     { 192-207 }
  288.      OTS_Black      = 216;     { 208-223 }
  289.      OTS_ExtraBlack = 232;     { 224-239 }
  290.      OTS_UltraBlack = 248;     { 240-255 }
  291.  
  292. { OT_SlantStyle is an unsigned byte indicating the font posture }
  293.      OT_SlantStyle  = (OT_Level1 OR $16);
  294.      OTS_Upright    = 0;
  295.      OTS_Italic     = 1;       { Oblique, Slanted, etc. }
  296.      OTS_LeftItalic = 2;       { Reverse Slant }
  297.  
  298. { OT_HorizStyle is an unsigned byte indicating the appearance width }
  299.      OT_HorizStyle  = (OT_Level1 OR $17);
  300.      OTH_UltraCompressed  =   16;     {   0- 31 }
  301.      OTH_ExtraCompressed  =   48;     {  32- 63 }
  302.      OTH_Compressed       =   80;     {  64- 95 }
  303.      OTH_Condensed        =  112;     {  96-127 }
  304.      OTH_Normal           =  144;     { 128-159 }
  305.      OTH_SemiExpanded     =  176;     { 160-191 }
  306.      OTH_Expanded         =  208;     { 192-223 }
  307.      OTH_ExtraExpanded    =  240;     { 224-255 }
  308.  
  309. { OT_SpaceFactor specifies the width of the space character relative
  310.  * to the character height }
  311.      OT_SpaceFactor = (OT_Level2 OR $18);
  312.  
  313. { OT_InhibitAlgoStyle indicates which ta_Style bits, if any, should
  314.  * be ignored even if the font does not already have that quality.
  315.  * For example, if FSF_BOLD is set and the typeface is not bold but
  316.  * the user specifies bold, the application or diskfont library is
  317.  * not to use OT_Embolden to achieve a bold result. }
  318.      OT_InhibitAlgoStyle = (OT_Level2 OR $19);
  319.  
  320. { OT_AvailSizes is an indirect pointer to sorted UWORDs, 0th is count }
  321.      OT_AvailSizes  = (OT_Level1 OR OT_Indirect OR $20);
  322.      OT_MAXAVAILSIZES    =   20;      { no more than 20 sizes allowed }
  323.  
  324. { OT_SpecCount is the count number of parameters specified here }
  325.      OT_SpecCount   = (OT_Level1 OR $100);
  326.  
  327. { Specs can be created as appropriate for the engine by ORing in the
  328.  * parameter number (1 is first, 2 is second, ... up to 15th) }
  329.      OT_Spec        = (OT_Level1 OR $100);
  330. { OT_Spec1 is the (first) parameter to the font engine to select
  331.  * this particular typeface }
  332.      OT_Spec1       = (OT_Level1 OR $101) ;
  333.  
  334.  
  335. const
  336. { PRELIMINARY }
  337.     OTERR_Failure        =  -1;      { catch-all for error }
  338.     OTERR_Success        =  0 ;      { no error }
  339.     OTERR_BadTag         =  1 ;      { inappropriate tag for function }
  340.     OTERR_UnknownTag     =  2 ;      { unknown tag for function }
  341.     OTERR_BadData        =  3 ;      { catch-all for bad tag data }
  342.     OTERR_NoMemory       =  4 ;      { insufficient memory for operation }
  343.     OTERR_NoFace         =  5 ;      { no typeface currently specified }
  344.     OTERR_BadFace        =  6 ;      { typeface specification problem }
  345.     OTERR_NoGlyph        =  7 ;      { no glyph specified }
  346.     OTERR_BadGlyph       =  8 ;      { bad glyph code or glyph range }
  347.     OTERR_NoShear        =  9 ;      { shear only partially specified }
  348.     OTERR_NoRotate       =  10;      { rotate only partially specified }
  349.     OTERR_TooSmall       =  11;      { typeface metrics yield tiny glyphs }
  350.     OTERR_UnknownGlyph   =  12;      { glyph not known by engine }
  351.  
  352. VAR BulletBase : pLibrary;
  353.  
  354. PROCEDURE CloseEngine(glyphEngine : pGlyphEngine);
  355. FUNCTION ObtainInfoA(glyphEngine : pGlyphEngine; tagList : pTagItem) : ULONG;
  356. FUNCTION OpenEngine : pGlyphEngine;
  357. FUNCTION ReleaseInfoA(glyphEngine : pGlyphEngine; tagList : pTagItem) : ULONG;
  358. FUNCTION SetInfoA(glyphEngine : pGlyphEngine; tagList : pTagItem) : ULONG;
  359.  
  360. IMPLEMENTATION
  361.  
  362. PROCEDURE CloseEngine(glyphEngine : pGlyphEngine);
  363. BEGIN
  364.   ASM
  365.     MOVE.L  A6,-(A7)
  366.     MOVEA.L glyphEngine,A0
  367.     MOVEA.L BulletBase,A6
  368.     JSR -036(A6)
  369.     MOVEA.L (A7)+,A6
  370.   END;
  371. END;
  372.  
  373. FUNCTION ObtainInfoA(glyphEngine : pGlyphEngine; tagList : pTagItem) : ULONG;
  374. BEGIN
  375.   ASM
  376.     MOVE.L  A6,-(A7)
  377.     MOVEA.L glyphEngine,A0
  378.     MOVEA.L tagList,A1
  379.     MOVEA.L BulletBase,A6
  380.     JSR -048(A6)
  381.     MOVEA.L (A7)+,A6
  382.     MOVE.L  D0,@RESULT
  383.   END;
  384. END;
  385.  
  386. FUNCTION OpenEngine : pGlyphEngine;
  387. BEGIN
  388.   ASM
  389.     MOVE.L  A6,-(A7)
  390.     MOVEA.L BulletBase,A6
  391.     JSR -030(A6)
  392.     MOVEA.L (A7)+,A6
  393.     MOVE.L  D0,@RESULT
  394.   END;
  395. END;
  396.  
  397. FUNCTION ReleaseInfoA(glyphEngine : pGlyphEngine; tagList : pTagItem) : ULONG;
  398. BEGIN
  399.   ASM
  400.     MOVE.L  A6,-(A7)
  401.     MOVEA.L glyphEngine,A0
  402.     MOVEA.L tagList,A1
  403.     MOVEA.L BulletBase,A6
  404.     JSR -054(A6)
  405.     MOVEA.L (A7)+,A6
  406.     MOVE.L  D0,@RESULT
  407.   END;
  408. END;
  409.  
  410. FUNCTION SetInfoA(glyphEngine : pGlyphEngine; tagList : pTagItem) : ULONG;
  411. BEGIN
  412.   ASM
  413.     MOVE.L  A6,-(A7)
  414.     MOVEA.L glyphEngine,A0
  415.     MOVEA.L tagList,A1
  416.     MOVEA.L BulletBase,A6
  417.     JSR -042(A6)
  418.     MOVEA.L (A7)+,A6
  419.     MOVE.L  D0,@RESULT
  420.   END;
  421. END;
  422.  
  423. END. (* UNIT BULLET *)
  424.  
  425.  
  426.  
  427.